#include <iostream>
#include <string>
// #include <memory>
using namespace std;

template <typename T>
class smart_pointer
{
private:
    T* m_pRawPointer;
public:
    smart_pointer(T* obj):m_pRawPointer(obj){} //constructor
    ~smart_pointer(){delete m_pRawPointer;}
    T& operator * () const //解除引用 derefencing operator
    {
        return *(m_pRawPointer);
    }

    T* operator ->() const //成员选择符
    {
        return m_pRawPointer;
    }
};

class Date
{
private:
    int Day, Month, Year;
    string DateString;
public:
    //Constructor that initiates the object to a day, month and year
    Date(int inputDay, int inputMonth, int inputYear):Day(inputDay), Month(inputMonth), Year(inputYear)
    {

    }

    void DisplayDate(void);
};
void Date::DisplayDate(void)
{
    cout << Year << "-" << Month << "-" << Day << endl;
}

int main(int argc, char const *argv[])
{
    smart_pointer<int> dynamicintPtr(new int(42));
    cout << *dynamicintPtr << endl;
    smart_pointer<Date> dynamicDate(new Date(6,4,2017));
    dynamicDate->DisplayDate();
    return 0;
}
